import request from 'utils/request';

// 获取所有频道数据
export const getChannels = () =>
  request({
    url: '/channels',
    method: 'get',
  });

// 获取文章列表
export const getArticleList = (params) =>
  request({
    url: '/mp/articles',
    method: 'get',
    params,
  });

// 删除文章
export const deleteArticles = (id) =>
  request({
    url: `/mp/articles/${id}`,
    method: 'DELETE',
  });

// 发布文章接口
export const publishArticles = ({ draft = false, ...data }) =>
  request({
    url: `/mp/articles?draft=${draft}`,
    method: 'post',
    data,
  });

// 获取文章详情
export const articlesDetail = (id) =>
  request({
    url: `/mp/articles/${id}`,
  });

// 编辑文章
export const artilesEdit = ({ draft, ...data }) =>
  request({
    url: `/mp/articles/${data.id}?draft=${draft}`,
    method: 'put',
    data,
  });
